package com.lovo.homework7_14ATM;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class QueryPanel extends JPanel implements ActionListener {
    private JButton jButton1;
    private JButton jButton2;
    private JButton jButton3;

    private Icon buttonIcon1 =util.Util.getIcon("/images/buttonSave.jpg");
    private Icon buttonIcon2 =util.Util.getIcon("/images/buttonGet.jpg");
    private Icon buttonIcon3 =util.Util.getIcon("/images/buttonOff.jpg");

    private JLabel jLabel1;
    private JLabel jLabel2;


    private ATMmain atMmain;

    public static int money;

    public JLabel getjLabel2() {
        return jLabel2;
    }

    public void setjLabel2(JLabel jLabel2) {
        this.jLabel2 = jLabel2;
    }

    public QueryPanel(ATMmain atMmain){
        this.atMmain=atMmain;

        this.setLayout(null);

        this.setOpaque(false);

        jLabel1=new JLabel("您的余额为：");
        jLabel1.setBounds(380,300,250,50);
        jLabel1.setForeground(Color.red);
        jLabel1.setFont(new Font("宋体",Font.BOLD,20));
        this.add(jLabel1);

        /*ArrayList<Users> users = atMmain.getUserList();
        str+=users.get(atMmain.getUser()).getMoney();
                jLabel2=new JLabel(str);*/


        jLabel2=new JLabel();
        jLabel2.setBounds(520,300,300,50);
        jLabel2.setForeground(Color.red);
        jLabel2.setFont(new Font("宋体",Font.BOLD,20));
        this.add(jLabel2);

        /*atMmain.setjLabelQuery(new JLabel());
        atMmain.getjLabelQuery().setBounds(520,300,300,50);
        atMmain.getjLabelQuery().setForeground(Color.red);
        atMmain.getjLabelQuery().setFont(new Font("宋体",Font.BOLD,20));
        this.add(atMmain.getjLabelQuery());*/

        jButton1=new JButton(buttonIcon1);
        jButton1.setBounds(210,400,140,50);
        this.add(jButton1);
        jButton1.addActionListener(this);

        jButton2=new JButton(buttonIcon2);
        jButton2.setBounds(450,400,140,50);
        this.add(jButton2);
        jButton2.addActionListener(this);

        jButton3=new JButton(buttonIcon3);
        jButton3.setBounds(690,400,140,50);
        this.add(jButton3);
        jButton3.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==jButton1){
            atMmain.switchPanel("depositPanel");
        }else if (e.getSource()==jButton2){
            atMmain.switchPanel("withDrawPanel");
        }else if (e.getSource()==jButton3){
            atMmain.switchPanel("loginPanel");
        }
    }

}
